#include "card.h"

// card 的构造函数
Card::Card() { }
Card::Card(CardPoint point, CardSuit suit){
    setPoint(point);
    setSuit(suit);
}

// card 点数的设置和获取
void Card::setPoint(CardPoint point){
    m_point = point;
}
Card::CardPoint Card::point() const{
    return m_point;
}

// card 花色的设置和获取
void Card::setSuit(CardSuit suit){
    m_suit = suit;
}
Card::CardSuit Card::suit() const{
    return m_suit;
}

// 从小到大排序
bool lessSort(const Card &c1, const Card &c2){
    if(c1.point() == c2.point())
        return c1.suit() < c2.suit();
    else
        return c1.point() < c2.point();
}
// 从大到小排序
bool greaterSort(const Card &c1, const Card &c2){
    if(c1.point() == c2.point())
        return c1.suit() > c2.suit();
    else
        return c1.point() > c2.point();
}

// 重载operator==运算符
bool operator ==(const Card& left, const Card& right){
    return (left.point() == right.point() && left.suit() == right.suit());
}
// 重载operator<运算符
bool operator <(const Card& c1, const Card& c2){
    return lessSort(c1, c2);
}

// hash
uint qHash(const Card &card){
    return card.point() * 100 + card.suit();
}



